package com.atzxh.java;

/**
 * 创建三个窗口卖票,一共100张
 *
 * @author 小红同学
 * @creat 2021-11-08-20:01
 * @description
 */
class Window extends Thread{                //此代码存在安全问题,以后学到再说....

    private static int ticket = 100;

    public void run() {
        while (true){
            if(ticket > 0){
                System.out.println(getName()+":"+ticket);
                ticket--;
            }else{
                break;
            }
        }
    }
}


public class WindowTest {
    public static void main(String[] args) {
        Window w1 = new Window();
        Window w2 = new Window();
        Window w3 = new Window();

        w1.setName("窗口1");
        w2.setName("窗口2");
        w3.setName("窗口3");

        w1.start();
        w2.start();
        w3.start();
    }
}
